package close.mazegame.entity.effect;


import box2dLight.PointLight;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.math.Vector2;

import close.mazegame.art.EffectTextures;
import close.mazegame.level.Level;

public class Explosion extends Effect {
	
	private static final float START_LIGHT_BRIGHTNESS = 1.0f;
	private static final float END_LIGHT_BRIGHTNESS = 0.0f;

	protected PointLight pl;
	

	public Explosion(Vector2 pos, Level level) {
		super(pos, level, EffectTextures.explosion, 0.1f, false);
		this.position = new Vector2(pos);
		pl = level.addPointLight(getX(), getY(), 16, new Color(1.0f, 0.7f, 0.4f, START_LIGHT_BRIGHTNESS), 1.5f, 0);
	}

	@Override
	public float getXSize() {
		return 1.0f; //Not sure why this has to be so big, must investigate
	}
	
	@Override
	public float getYSize() {
		return 1.0f; //Not sure why this has to be so big, must investigate
	}

	@Override
	public void dispose() {
		pl.remove();
	}

	@Override
	public void update(float delta) {
		super.update(delta);
		float lightStrength = Interpolation.sineIn.apply(START_LIGHT_BRIGHTNESS, END_LIGHT_BRIGHTNESS, getAnimationFraction());
		pl.setColor(new Color(1.0f, 0.7f, 0.4f, lightStrength));
	}

}
